//
//  MyHomeTableViewCell2.m
//  FruitsWholesaler
//
//  Created by sgone-2 on 16/4/11.
//  Copyright © 2016年 sgone. All rights reserved.
//

#import "MyHomeTableViewCell2.h"
#import "Common.h"
@implementation MyHomeTableViewCell2


- (void)setFrame:(CGRect)frame {
    
    frame.size.width = ViewWidth;
    [super setFrame:frame];
}


+ (instancetype)cellWithTableView:(UITableView *)tableView
{
   NSString *ID = @"MyHomeTableViewCell2";
    MyHomeTableViewCell2 *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        
        cell = [[NSBundle mainBundle]loadNibNamed:@"MyHomeTableViewCell2" owner:nil options:nil][0];
   
    }
    return cell;

}


-(void)setMyCell
{
    self.backgroundColor = [UIColor whiteColor];
    if (self.row == 0) {
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ViewWidth, 0.5)];
        view.backgroundColor = BACKGROUND1;
        [self addSubview:view];
        
        
        
        UIView *view2 =  [[UIView alloc]initWithFrame:CGRectMake(0, 100 / FDLaOt - 1, ViewWidth, 1)];
        view2.backgroundColor = BACKGROUND1;
        [self addSubview:view2];
     }
    
    for (int i = 0; i < 3; i++) {
        self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width / 3 / 2 / 2 + self.width / 3 * i, self.width / 10 / 3 - 2 / FDLaOt + 3 / FDLaOt, self.width / 2 / 3, self.width / 2 / 3)];
        self.iconImageView.contentMode = UIViewContentModeCenter;
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(i * self.width / 3, 100 / FDLaOt - 20 / FDLaOt - 1 / FDLaOt - self.iconImageView.y, self.width / 3, 20)];
        self.titleLabel.font = [UIFont systemFontOfSize:14.0f];
        self.titleLabel.textColor = [UIColor grayColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        
        self.btnCai = [[UIButton alloc] initWithFrame:CGRectMake(i * self.width / 3, 0, ViewWidth / 3, 100 / FDLaOt)];
        
        self.btnCai.tag = 1100 + i;
  
        [self.btnCai addTarget:self action:@selector(goToOtherClick:) forControlEvents:UIControlEventTouchUpInside];
        
        self.iconImageView.image = [UIImage imageNamed:self.array1[(int)self.row * 3 + i]];
        
        self.titleLabel.text = [NSString stringWithFormat:@"%@",self.array2[(int)self.row * 3 + i]];
        
        if (i > 0) {
            
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(ViewWidth / 3 * i, 0, 1, 100 / FDLaOt)];
            view.backgroundColor = BACKGROUND1;
            [self addSubview:view];

    }
    
        
        
        [self addSubview:self.iconImageView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.btnCai];
    }

    
    
    
    if (self.row == 1) {
        
        UIView *view2 =  [[UIView alloc]initWithFrame:CGRectMake(0, 100 / FDLaOt - 1, ViewWidth / 3 * 3, 1)];
        view2.backgroundColor = BACKGROUND1;
        [self addSubview:view2];
      
    }

}


- (void)goToOtherClick:(id)sender {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"goToHomeClick" object:nil userInfo:@{@"tag":[NSString stringWithFormat:@"%d",[sender tag] - 1100],@"row":[NSString stringWithFormat:@"%d",self.row]}];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
  
}

@end
